package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.BEng_af;
import com.ruoyi.system.service.IBEng_afService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 电子工程表相关功能Controller
 * 
 * @author Zzr
 * @date 2023-09-20
 */
@RestController
@RequestMapping("/system/eeng")
public class BEng_afController extends BaseController
{
    @Autowired
    private IBEng_afService bEEngService;

    /**
     * 查询电子工程表相关功能列表
     */
    //@PreAuthorize("@ss.hasPermi('system:eng:list')")
    @GetMapping("/list")
    public TableDataInfo list(BEng_af bEEng)
    {
        startPage();
        List<BEng_af> list = bEEngService.selectBEEngList(bEEng);
        return getDataTable(list);
    }

    @GetMapping("/listZeroOne")
    public TableDataInfo listZeroOne(BEng_af bEEng){
        startPage();
        List<BEng_af> list = bEEngService.listZeroOne(bEEng);
        return getDataTable(list);
    }

    @GetMapping("/listTwoThreeFour")
    public TableDataInfo listTwoThreeFour(BEng_af bEEng){
        startPage();
        List<BEng_af> list = bEEngService.listTwoThreeFour(bEEng);
        return getDataTable(list);
    }


    @GetMapping("/noBandList")
    public TableDataInfo noBandList(BEng_af bEEng)
    {
        bEEng.setProjectStatus((long) 2);
        startPage();
        List<BEng_af> list = bEEngService.selectBEEngList(bEEng);
        return getDataTable(list);
    }

    @GetMapping("/BandList")
    public TableDataInfo BandList(BEng_af bEEng)
    {
        bEEng.setProjectStatus((long) 4);
        startPage();
        List<BEng_af> list = bEEngService.selectBEEngList(bEEng);
        return getDataTable(list);
    }
    /**
     * 导出电子工程表相关功能列表
     */
    //@PreAuthorize("@ss.hasPermi('system:eng:export')")
    @Log(title = "电子工程表相关功能", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BEng_af bEEng)
    {
        List<BEng_af> list = bEEngService.selectBEEngList(bEEng);
        ExcelUtil<BEng_af> util = new ExcelUtil<BEng_af>(BEng_af.class);
        util.exportExcel(response, list, "电子工程表相关功能数据");
    }

    /**
     * 获取电子工程表相关功能详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:eng:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(bEEngService.selectBEEngById(id));
    }

    /**
     * 新增电子工程表相关功能
     */
    //@PreAuthorize("@ss.hasPermi('system:eng:add')")
    @Log(title = "电子工程表相关功能", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BEng_af bEEng)
    {
        return toAjax(bEEngService.insertBEEng(bEEng));
    }

    /**
     * 修改电子工程表相关功能
     */
    //@PreAuthorize("@ss.hasPermi('system:eng:edit')")
    @Log(title = "电子工程表相关功能", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BEng_af bEEng)
    {
        return toAjax(bEEngService.updateBEEng(bEEng));
    }

    /**
     * 审核通过
     */
    //@PreAuthorize("@ss.hasPermi('system:eng:edit')")
    @Log(title = "电子工程表审核通过", businessType = BusinessType.UPDATE)
    @PostMapping("/passBEEng")
    public AjaxResult passBEEng(@RequestBody BEng_af bEEng)
    {
        return toAjax(bEEngService.passBEEng(bEEng));
    }

    /**
     * 审核不通过
     */
    //@PreAuthorize("@ss.hasPermi('system:eng:edit')")
    @Log(title = "电子工程表审核不通过", businessType = BusinessType.UPDATE)
    @PostMapping("/failPassBEEng")
    public AjaxResult failPassBEEng(@RequestBody BEng_af bEEng)
    {
        return toAjax(bEEngService.failPassBEEng(bEEng));
    }

    /**
     * 删除电子工程表相关功能
     */
    //@PreAuthorize("@ss.hasPermi('system:eng:remove')")
    @Log(title = "电子工程表相关功能", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(bEEngService.deleteBEEngByIds(ids));
    }
}
